﻿using ConfigServices;
using LogServices;
using System;
using System.Collections.Generic;
using System.Text;

namespace MailServices
{
    public class MailService : IMailService
    {
        private readonly ILogProvider log;
        //private readonly IConfigService config;
        private readonly IConfigReader config;

        //public MailService(ILogProvider log, IConfigService config)
        public MailService(ILogProvider log, IConfigReader config)
        {
            this.log = log;
            this.config = config;
        }

        public void Send(string title, string to, string body)
        {
            log.LogInfo("准备发送邮件");
            string smtpServer = config.GetValue("SmtpServer");
            string userName = config.GetValue("UserName");
            string password = config.GetValue("Password");

            Console.WriteLine($"邮件配置 {smtpServer} {userName} {password}");
            Console.WriteLine($"发送邮件 {title} {to}。");
            log.LogInfo("邮件发送完成");
        }
    }
}
